﻿using Max.Ph5_2009A.NewShopping.Domain;
using Max.Ph5_2009A.NewShopping.Domain.Shared;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Max.Ph5_2009A.NewShopping.DTO
{
    /// <summary>
    /// 创建订单输入的DTO
    /// 2023/4/8
    /// </summary>
    public class CreateOrderInputDto
    {
        #region 订单信息
        public CreateOrderMasterInputDto OrderMaster { get; set; }       
        #endregion

        #region 订单明细（商品信息）
        public List<CreateOrderDetailInputDto> OrderDetails { get; set; }
        #endregion
    }

    /// <summary>
    /// 订单主表信息DTO
    /// </summary>
    public class CreateOrderMasterInputDto
    {
        #region 收件人信息
        //冗余字段
        public string? RecivedName { get; set; }
        public string? RecivedPhone { get; set; }
        public string? RecivedAddress { get; set; }

        #endregion

        #region 订单具体信息

        /// <summary>
        /// 订单编号
        /// </summary>
        [Required(ErrorMessage = "订单编号不能为空")]
        public string OrderNo { get; set; }

        /// <summary>
        /// 会员ID（谁下的单）
        /// </summary>
        public Guid MemberId { get; set; }

        /// <summary>
        /// 订单金额
        /// </summary>
        public decimal Total { get; set; }


        /// <summary>
        /// 优惠金额
        /// </summary>
        public decimal DiscountMoney { get; set; } = 0;

        #endregion

        #region 支付信息
        /// <summary>
        /// 支付金额
        /// </summary>
        public decimal PayMoney { get; set; }

        /// <summary>
        /// 支付方式
        /// </summary>
        public OrderPayState PayType { get; set; } = OrderPayState.WeiXin;

        /// <summary>
        /// 支付时间
        /// </summary>
        public DateTime PayTime { get; set; }

        #endregion

    }

    /// <summary>
    /// 创建订单明细DTO
    /// </summary>
    public class CreateOrderDetailInputDto
    {
        /// <summary>
        /// 订单编号
        /// </summary>
        public string OrderNo { get; set; }

        /// <summary>
        /// 商品ID
        /// </summary>
        public Guid GoodsId { get; set; }

        /// <summary>
        /// 商品数量
        /// </summary>
        public int GoodsNumber { get; set; }

        /// <summary>
        /// 商品价格
        /// </summary>
        public decimal GoodsPrice { get; set; }
    }
}
